package edu.szcu.vitaguard.dao;

import edu.szcu.vitaguard.entity.DictRegStatus;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 预约状态字典DAO接口
 */
@Mapper
public interface DictRegStatusDao {

    /**
     * 插入预约状态
     * @param dictRegStatus 预约状态对象
     * @return 影响的行数
     */
    @Insert("INSERT INTO dict_reg_status(status_name, description, create_time) " +
            "VALUES(#{statusName}, #{description}, #{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "statusId")
    int insert(DictRegStatus dictRegStatus);

    /**
     * 根据ID查询预约状态
     * @param statusId 预约状态ID
     * @return 预约状态对象
     */
    @Select("SELECT * FROM dict_reg_status WHERE status_id = #{statusId}")
    DictRegStatus selectById(Integer statusId);

    /**
     * 查询所有预约状态
     * @return 预约状态列表
     */
    @Select("SELECT * FROM dict_reg_status")
    List<DictRegStatus> selectAll();

    /**
     * 根据状态名称查询预约状态
     * @param statusName 预约状态名称
     * @return 预约状态对象
     */
    @Select("SELECT * FROM dict_reg_status WHERE status_name = #{statusName}")
    DictRegStatus selectByName(String statusName);

    /**
     * 更新预约状态
     * @param dictRegStatus 预约状态对象
     * @return 影响的行数
     */
    @Update("UPDATE dict_reg_status SET status_name = #{statusName}, " +
            "description = #{description} WHERE status_id = #{statusId}")
    int update(DictRegStatus dictRegStatus);

    /**
     * 删除预约状态
     * @param statusId 预约状态ID
     * @return 影响的行数
     */
    @Delete("DELETE FROM dict_reg_status WHERE status_id = #{statusId}")
    int deleteById(Integer statusId);
}
